/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelRadio.java
 *
 * Created on 18/01/2012, 03:02:32 PM
 */

package GUI;

import Control.*;
import Entidad.Archivoaudio;
import java.util.List;
import javax.swing.JLabel;

/**
 *
 * @author Andrés 2
 */
public class PanelRadio extends javax.swing.JPanel {
    
    /** Creates new form PanelRadio */
    public PanelRadio() {
      //  LabelDato.setText(MenuP.Dato);
        initComponents();
     }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        jFrame2 = new javax.swing.JFrame();
        jScrollPane1 = new javax.swing.JScrollPane();
        TPendRadio = new javax.swing.JTable();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        TRevRadio = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jFrame2Layout = new javax.swing.GroupLayout(jFrame2.getContentPane());
        jFrame2.getContentPane().setLayout(jFrame2Layout);
        jFrame2Layout.setHorizontalGroup(
            jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        jFrame2Layout.setVerticalGroup(
            jFrame2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );

        addContainerListener(new java.awt.event.ContainerAdapter() {
            public void componentAdded(java.awt.event.ContainerEvent evt) {
                formComponentAdded(evt);
            }
        });
        addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                formFocusGained(evt);
            }
        });

        TPendRadio.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Id", "Nombre", "Ruta", "Emisora", "Duración", "Fecha Grabación"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Long.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane1.setViewportView(TPendRadio);

        jLabel2.setText("PENDIENTES");

        TRevRadio.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Id", "Nombre", "Ruta", "Emisora", "Duración", "Fecha Grabación"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class, java.lang.Long.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(TRevRadio);

        jLabel3.setText("REVISADOS");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3))
                .addGap(20, 20, 20))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
                .addGap(45, 45, 45))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void formFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_formFocusGained
 
        // TODO add your handling code here:
    }//GEN-LAST:event_formFocusGained

    private void formComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_formComponentAdded
     
        // TODO add your handling code here:
    }//GEN-LAST:event_formComponentAdded


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable TPendRadio;
    private javax.swing.JTable TRevRadio;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JFrame jFrame2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables

    public void setTPendRadio(String emiso) {
         
        ArchivoaudioJpaController archivoaudioJpaController = new ArchivoaudioJpaController();
        List list = archivoaudioJpaController.encontrarArchivoAudioPorEmisorNoCheckeado(emiso);
        
        
        for (int i = 0; i < list.size(); i++)
        {
            Archivoaudio archivoaudio = (Archivoaudio) list.get(i);
            TPendRadio.setValueAt(String.valueOf(archivoaudio.getIdArchivoAudio()), i, 0);
            TPendRadio.setValueAt(String.valueOf(archivoaudio.getNombre()), i, 1);
            TPendRadio.setValueAt(String.valueOf(archivoaudio.getUrl()), i, 2);
            TPendRadio.setValueAt(emiso, i, 3);
            TPendRadio.setValueAt(String.valueOf(archivoaudio.getDuracion()), i, 4);
            TPendRadio.setValueAt(String.valueOf(archivoaudio.getFechaDeGrabacion()), i, 5);   
        }
        
       
    }
    
    public void setTRevRadio(String emiso) {
         
        ArchivoaudioJpaController archivoaudioJpaController = new ArchivoaudioJpaController();
        List list = archivoaudioJpaController.encontrarArchivoAudioPorEmisorCheckeado(emiso);
     
        for (int i = 0; i < list.size(); i++)
        {
            Archivoaudio archivoaudio = (Archivoaudio) list.get(i);
            TRevRadio.setValueAt(String.valueOf(archivoaudio.getIdArchivoAudio()), i, 0);
            TRevRadio.setValueAt(String.valueOf(archivoaudio.getNombre()), i, 1);
            TRevRadio.setValueAt(String.valueOf(archivoaudio.getUrl()), i, 2);
            TRevRadio.setValueAt(emiso, i, 3);          
            TRevRadio.setValueAt(String.valueOf(archivoaudio.getDuracion()), i, 4);
            TRevRadio.setValueAt(String.valueOf(archivoaudio.getFechaDeGrabacion()), i, 5);   
        }
        
       
    }



}
